<?php
	// set up database info
	$usr = "flytalk";
	$pwd = "ft1234";
	$db = "flytalk";
	$host = "yangjustine.startlogicmysql.com";

	// establish connection
	$connection = mysql_connect($host,$usr,$pwd);
	if (!$connection) { echo("ERROR: " . mysql_error() . "\n"); }
	
	
	// test method to get last users
	$sql = 'SELECT * FROM `User`';
    $users = mysql_db_query($db,"$sql",$connection);
	$user_list = array();
	if (!$users) {
    		echo("ERROR: " . mysql_error() . "\n$SQL\n"); 	
	}
	else{
		// multiple users  
		
		while($row = mysql_fetch_array($users))
		{
			
			 $user_list[] = array(
                'username' => $row['username'],
                'firstname' => $row['firstname'],
                'lastname' => $row['lastname'],
                'date' => $row['dateCreated']
            );      
		}
		
		// $cb = isset($_GET['callback']) ? $_GET['callback'] : '';
       
   //  echo $cb . '({"results":' . json_encode($user_list) . '})';
	 $callback = $_GET['callback'];

	if ($callback) {
    header('Content-Type: text/javascript');
    echo $callback . '({"results":' . json_encode($user_list) . '});';
} else {
    header('Content-Type: application/x-json');
    echo json_encode($user_list);
}


	}

	//mysql_close($connection);

?>